<?php
namespace App\Console\Commands;

use App\Jobs\Order\OrderSyncToEsJob;
use Illuminate\Console\Command;
use App\Facade\Elastic\ElasticsearchFacade;

class ElasticsearchIndexCommand extends Command
{
    protected $signature = 'es:index';
    protected $description = '创建es索引投递任务';

    public function handle()
    {
        $startId = 100000;
        $endId = 110000;
        for ($i = $startId; $i <= $endId; $i += 500) {
            // OrderSyncToEsJob::dispatch($i, $i + 500);
            //投递任务到 rabbitmq 队列
            OrderSyncToEsJob::dispatch($i, $i + 500)->onConnection('rabbitmq');
        }
        return 0;
    }
}